今天來解YKL03(UVA10812):Beat the Spread!
給一個s(sum)和d(difference)
要output最後比賽的分數
( s + d ) / 2
( s - d ) / 2
s 一定要大於 d
且相加要是偶數
#include <iostream>
using namespace std;
int main(){
int s,d,cases;
cin >> cases;
while(cases){
int a,b;
cin >> s >> d;
if((s + d) % 2 == 0 && (s - d) % 2 == 0){
a = (s + d) / 2;
b = (s - d) / 2;
if(a >= 0 && b >= 0){
cout << a << " " << b << endl;
}
else{
cout << "impossible" << endl;
}
}else{
cout << "impossible" << endl;
}
cases--;
}
return 0;
}